﻿using System.Windows;

namespace ComicQ.View
{
    /// <summary>
    /// Interaction logic for ComicView.xaml
    /// </summary>
    public partial class ComicView
    {
        public ComicView()
        {
            InitializeComponent();
        }

        private void ButtonAddClick(object sender, RoutedEventArgs e)
        {
            //var newWindow = new ComicEditorView(_comics);

            //if (newWindow.ShowDialog() != false)
            //{
            //}
            //else
            //{
            //    try
            //    {
            //        if (newWindow.Output == null)
            //            throw new NullReferenceException();

            //        _comics.Add(newWindow.Output);
            //        dataGridComic.ItemsSource = null;
            //        dataGridComic.ItemsSource = _comics;
            //    }
            //    catch (NullReferenceException)
            //    {
            //        MessageBox.Show("Tidak jadi menambah comic.");
            //    }
            //}
        }

        private void ButtonDeleteClick(object sender, RoutedEventArgs e)
        {
            //try
            //{
            //    if (dataGridComic.SelectedItem == null)
            //        throw new NullReferenceException();

            //    _comics.RemoveAt(dataGridComic.SelectedIndex);
            //    dataGridComic.ItemsSource = null;
            //    dataGridComic.ItemsSource = _comics;
            //}
            //catch (NullReferenceException)
            //{
            //    MessageBox.Show("Pilih yang mau didelete.");
            //}
        }

        private void ButtonEditClick(object sender, RoutedEventArgs e)
        {
            //try
            //{
            //    if (dataGridComic.SelectedItem == null)
            //        throw new NullReferenceException();

            //    var newWindow = new ComicEditorView(_comics[dataGridComic.SelectedIndex]);

            //    if (newWindow.ShowDialog() != false)
            //    {
            //    }
            //    else
            //    {
            //        try
            //        {
            //            if (newWindow.Output == null)
            //                throw new NullReferenceException();

            //            _comics.RemoveAt(dataGridComic.SelectedIndex);
            //            _comics.Insert(dataGridComic.SelectedIndex, newWindow.Output);
            //            dataGridComic.ItemsSource = null;
            //            dataGridComic.ItemsSource = _comics;
            //        }
            //        catch (NullReferenceException)
            //        {
            //            MessageBox.Show("Tidak jadi mengedit comic.");
            //        }
            //    }
            //}
            //catch (NullReferenceException)
            //{
            //    MessageBox.Show("Pilih yang mau diedit.");
            //}
        }
    }
}
